package cn.iocoder.yudao.module.blog.dal.mysql.posteruser;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.blog.dal.dataobject.posteruser.PosterUserDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.blog.controller.admin.posteruser.vo.*;

/**
 * 用户海报信息 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface PosterUserMapper extends BaseMapperX<PosterUserDO> {

    default PageResult<PosterUserDO> selectPage(PosterUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PosterUserDO>()
                .eqIfPresent(PosterUserDO::getUserId, reqVO.getUserId())
                .likeIfPresent(PosterUserDO::getName, reqVO.getName())
                .eqIfPresent(PosterUserDO::getMobile, reqVO.getMobile())
                .betweenIfPresent(PosterUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PosterUserDO::getId));
    }

    default List<PosterUserDO> selectList(PosterUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PosterUserDO>()
                .eqIfPresent(PosterUserDO::getUserId, reqVO.getUserId())
                .likeIfPresent(PosterUserDO::getName, reqVO.getName())
                .eqIfPresent(PosterUserDO::getMobile, reqVO.getMobile())
                .betweenIfPresent(PosterUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PosterUserDO::getId));
    }

    default PosterUserDO selectByUserId(Long userId){
        return selectOne(PosterUserDO::getUserId, userId);
    }

}
